package service;

import dao.ImplementUser;
import pojo.User;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

@WebServlet("/areaUsersServlet")
public class AreaUsersServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String type=req.getParameter("type");
        ArrayList<User> areausers=new ArrayList<>();
        ImplementUser implementUser=new ImplementUser();
        try {
            areausers=implementUser.areaUsers(type);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        req.setAttribute("areausers",areausers);
        req.getRequestDispatcher("/areaUsers").forward(req,resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}
